<template>
  <div class="sex_container">
    <div class="top">
      <div class="left">
        <p>男女比例</p>
        <p class="left_bg"></p>
      </div>
    </div>
    <div class="main">
      <div class="people">
        <div class="man">
          <img src="../../../../assets/images/screen/man.png" alt="man" />
          <p>男士58%</p>
        </div>
        <div class="woman">
          <img src="../../../../assets/images/screen/woman.png" alt="woman" />
          <p>女士42%</p>
        </div>
      </div>
      <div class="charts" ref="charts"></div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
//获取图形图标的DOM节点
let charts = ref();
onMounted(() => {
  //初始化echarts实例
  let mycharts = echarts.init(charts.value);
  //设置配置项
  mycharts.setOption({
    //组件标题
    title: {
      text: "男女比例",
      textStyle: {
        //主标题颜色
        color: "skyblue",
        fontSize: "16px",
      },
      left: "40%",
    },
    //x|y
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: "category",
    },
    series: [
      {
        type: "bar",
        data: [58],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: "skyblue",
          borderRadius: 20,
        },
      },
      {
        type: "bar",
        data: [100],
        barWidth: 20,
        //调整女士柱条位置
        barGap: "-100%",
        itemStyle: {
          color: "pink",
          borderRadius: 20,
        },
      },
    ],
    grid: {
      left: 80,
      top: 15,
      right: 80,
      bottom: 0,
    },
  });
});
</script>

<style scoped lang="scss">
.sex_container {
  background: url(../../../../assets/images/screen/dataScreen-main-cb.png)
    no-repeat;
  background-size: 100% 100%;

  .top {
    display: flex;
    justify-content: space-between;
    height: 54px;
    padding: 10px;
    color: white;

    .left {
      .left_bg {
        width: 68px;
        height: 8px;
        margin-top: 12px;
        background: url(../../../../assets/images/screen/dataScreen-title.png);
        background-size: 100% 100%;
      }
    }
  }

  .main {
    height: calc(100% - 54px);
    padding: 10px;

    .people {
      display: flex;
      justify-content: center;

      .woman,
      .man {
        margin-top: 10px;
        padding: 26px 26px 10px;
        background: url(../../../../assets/images/screen/man-bg.png) no-repeat;

        p {
          color: white;
          margin: 6px 0;
        }
      }

      .woman {
        margin-left: 24px;
        background: url(../../../../assets/images/screen/woman-bg.png) no-repeat;
      }
    }

    .charts {
      height: calc(100% - 140px);
    }
  }
}
</style>
